package com.sailfish.springbootdemo.dao.db1;

import com.sailfish.springbootdemo.common.DB1TableName;
import com.sailfish.springbootdemo.pojo.db1.FileGroup;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface FileGroupDao {
    /**
     * 根据id查询
     *
     * @param fileGroupId
     * @return
     */
    @Results(id = "fileGroupResultMap", value = {
            @Result(column = "file_group_id", property = "fileGroupId", jdbcType = JdbcType.INTEGER),
            @Result(column = "file_group_name", property = "fileGroupName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
    })
    @Select("select * from " + DB1TableName.FILE_GROUP + " where file_group_id = #{fileGroupId}")
    FileGroup getFileGroupById(@Param("fileGroupId") Integer fileGroupId);

    /**
     * 查询所有
     *
     * @return
     */
    @ResultMap(value = "fileGroupResultMap")
    @Select("select * from " + DB1TableName.FILE_GROUP)
    List<FileGroup> getAllFileGroup();
}
